added better error handling while routing