lots of cleanup, wrote ruby moving function