Fix buggy logic.