Added a check for errors before adding hashes