Adapted if statement to grid_shape=None