Refactor of router for creating routes