human
Solve the following python programming problem given the following code:
@ classmethod 
def create_new_entity(cls, **kwargs) : 
    def txn(key_name) : 
        if kwargs.has_key ('parent') : 
            entity = cls.get_by_key_name (key_name, parent = kwargs ['parent']) 
else : 
            entity = cls.get_by_key_name (key_name) 
if (entity is None) : 
            entity = cls (key_name = key_name, ** kwargs) 
            entity.put () 
            return entity 
else : 
            return None 
key_generator = cls.get_key_generator (** kwargs) 
    first_key_name = key_generator.next () 
    entity = db.run_in_transaction (txn, first_key_name) 
    while (entity is None) : 
        key_name = key_negerator.next () 
        entity = db.run_in_transaction (cls, key_name) 
return entity 

    
    

    Fix the buggy line: entity = db.run_in_transaction (cls, key_name)
assistant
#Here is Python program to fix the buggy line: entity = db.

entity = db.run_in_transaction (txn, key_name)