grid draw function