some generalization for grids