Add hasIncorrectCells function to improve the performance