moved logic for route building