Fix logic error

--some logic updates