modified the way of drawing grid