implement grids while removing some unnecessary code