refactoring code adn adding routes
after the refactoring and adding some routes