fixed generate_key() when adding entries