refactored routes and redirection logic