Modified grid.h