fixed a logic error