MI_algorithm almost done!