db driven routes function