refactor route building