for when it performs the function of changing the chameleon's color, the changed color benefits the chameleon by (sometimes) further effecting predation avoidance.
(it; performs; the function of changing the chameleon's color)
it
performs
the function of changing the chameleon's color