added the grid reset and switched the spot of i and j in cell variable