fix missing import and NameError