refactoring move function