add maths for snapping to grid