Refactored code in the routes to render the views dy dynamically.