Doing algebra without the normal commuting rules is super unintuitive for me. Did I do this right?

"If G is a group and , write in terms of and "

What I did (I'm doing all of my operations on the right hand side):

Is that right? It seems weird to me that splitting the h and g would make them switch places.