automated snapping, should be imrpoved later on