Attempt to fix error handling