grid calculation fix