fixed some logic condition