refactoring move logic to view.