implementation for checkGrid