refactored check_hash (pep8)