Change long line of (x?y:z) statements to set of if clauses