sin x was factored out of the expression just as you would if you had something like

(-1 was factored out of the bracketed expression)

Recall that:

Substituting it in, we get:

since

----------------------------

Focusing on the red, let's factor out and for the blue, let's factor out -1:

Factor out (sec x - 1):

And hopefully the expression in purple reminds you of a certain identity.