changing to MVC structure for cleaner code