Fixed logic error