Fixing issues #3 for M2, quantum cost calcualtion