Change order of operations in spatial_grid_dep