refactoring to follow MVC