Quark optimizations - replaced ifs with condiational operators