Fixed a minor logic error