fixing grid_index issue