New mb calculation code