fixed logic failure