added a efficient way to draw the grid