fix some logic error