code for generating MBB