fix "not None" logic error