Fixed ternary operator
Got rid of qm temporary functions