Fixed minor logic error