fixed logic error

fixed logic error