Handling the drawing of the grid