refactored controllers and routes