More work on movement funciton. Not working right yet.