extract a draw grid function