Factor out grid