refactoring and adding routing system