Fix NoneType comparison