You don't need the comparison to 3. It is enough to use:
Code:
if checkCell(cells,i,j) && (numberOfNeighbors(cells,i,j) == 2)
Because the next if statement will compare to 3.