fixed gridding error

differences between DEBUG and BUILD mode caused values to change
unexpectedly