Refactoring to respect Model-View-Controller