traversal of the grid