fixed logic issue