fixing bug and small routing refactoring