expanded iteration and variable substitution explanation