Fixed invalid logic