refactor motion service, but not tested