changed error handling