Fixed a minor logic bug