added createGrid() function