Made route both return the function and set the function
Refactored function passing to keep track of detail