Fix minor logic error