Refactoring step 4 to use dynamic routes