Update grid.cpp

Fixed, based on suggestion from R.B.