fix some logic