fix bug with smaller grid count.