I think this code will fail if the hash passed is empty