added jon's motion code