Fixed minor logic bug