wraps movement in function