Corrected ternary operation order - credit to Dean