migrating routes logic to routes file