Added dx and dy for grid traversal.