fixed up error handling and routes