Added None check for hash in add_hash