fix name error: global name `self` does not exist