refactoring to be more MVC