started refactoring, moved some user interaction to view