changed logic for check_hash