Trying to rebuild createGrid function