improved the generation of the reverse second order functions by using coloring (not applied to loops yet)