refactor routes and controllers