cleaned up the moveend function slightly