Fixed a logic error