added MotionChange events
change temporary fields to local variables