Fixes a logic error