rewrote the QMC part