Convert to MVC pattern-design