fixed logic error bug