added support for non uniform grids