refactoring + preparing for mvc