factored out make_hash