fix NoneType error