Update mim.js

Though this logic increases the size of the file it works faster than the old logic.