Fix logic flaw