Changed stuff so it reads more like a MVC pattern