refactored route code