calculating motion