improved misr_inv's performance by about 90%