Fixed a bug in the grid check