fix grid traverse algorithm