rewritten if logic for hashes