added gridSize check
added comments