Expanded parameters to convert
Unnest ifs
Renamed variables, adjusted parameters