nested if to flattened structure conversion...