Starting to fix error handling bug