fix a NoneType bug