fixed bug in mainQuadCode