better error handling with router