fixed logic in if