Refactorin step 4 to use dynamic routes