Fix possible logic error