fixed bug for case a(a_mid) == b(b_mid)