Slight factoring to follow a MVC pattern