mia almost finalized without optimizations