Minor refactoring of dynamic route handler