refactored mi.js again