fixed bugs in offscreen drawing grid