fixes error handling