fix and refactor routes