switched to postgresql
logic for generating grids