refactor with hashes