implemented snap to grid