added error handling
fixed issue where routing was registered too early