changed error handling and routes