implements snapping to center