Fix buggy conditions