updated motion function