Same as before, just fixed some logic error