Changed variables and conditional to ternary