Possible fix for error handling