fixed error calculation in grid width (now calculates inner width)