grid.h: fix one logic bug