refactoring routes and controllers