Homomorphism between $ S_n $ and the group of Automorphisms of a group of direct product here I am referring to the Problem 8 of the Exercise for Section 5.1 from Dummit Foote. The problem refers to the previous problem which reads:

Let $ G_{1},\dots,G_{n} $ be groups and let $ \sigma\in S_{n} $ be fixed. Prove that the map $$ \varphi_{\sigma}:G_{1}\times \dots\times G_{n}\to G_{\sigma^{-1}(1)}\times \dots\times G_{\sigma^{-1}(n)} $$ defined by $$ \varphi_{\sigma}(g_1,\dots,g_n)=\big(g_{\sigma^{-1}(1)},\dots,g_{\sigma^{-1}(n)}\big) $$ is an isomorphism.

Now problem 8 reads as the following:

In the above exercise, let $ G_1=\dots=G_{n} $, and call $ G=G_1\times \dots\times G_{n} $. Then show that for every permutation $ \sigma\in S_{n} $, the map $ \varphi_{\sigma} $ is an automorphism on $ G $. Also show that the map $ \sigma\mapsto\varphi_{\sigma} $ is an injective homomorphism of $ S_{n} $ into $ \mathscr{A}(G) $, where $ \mathscr{A}(G) $ is the group of automorphisms of $ G $.

I am having trouble with the homomorphism part. I know that I am making a very silly mistake, but cannot find the same. My argument is the following:
For any arbitrary element $ (g_1,\dots,g_n)\in G $ and for arbitrary permutations $ \sigma,\tau\in S_n $, we have
$$\begin{align}
  \varphi_{\sigma\circ\tau}(g_1,\dots,g_n) &= \big(g_{(\sigma\circ\tau)^{-1}(1)}, \dots,g_{(\sigma\circ\tau)^{-1}(n)}\big)\\
  &= \big(g_{(\tau^{-1}\circ\sigma^{-1})(1)},\dots,g_{(\tau^{-1}\circ\sigma^{-1})(n)}\big)\\
  &= \big(g_{(\tau^{-1}(\sigma^{-1})(1))},\dots,g_{(\tau^{-1}(\sigma^{-1})(n))}\big)\\
  &= \varphi_{\tau}\big(g_{\sigma^{-1}(1)},\dots,g_{\sigma^{-1}(n)}\big)\\
  &= \varphi_{\tau}\big(\varphi_{\sigma}(g_1,\dots,g_n)\big)\\
  &= (\varphi_{\tau}\circ\varphi_{\sigma})(g_1,\dots,g_n).
 \end{align}$$
Therefore, $ \varphi_{\sigma\circ\tau}=\varphi_{\tau}\circ\varphi_{\sigma} $.
So, the order of the maps has reversed. I cannot seem to find a mistake. Please help.
 A: This is tricky, and the computation has to be done carefully. There is a bit of a surprise in it. Here we go:
The $j$th coordinate of $\varphi_{\rho}(g_1,\ldots,g_n)$ is the $\rho^{-1}(j)$th coordinate of $(g_1,\ldots,g_n)$.
So the $j$th coordinate of $\varphi_{\tau}(\varphi_{\sigma}(g_1,\ldots,g_n))$ is the $\tau^{-1}(j)$th coordinate of $\varphi_{\sigma}(g_1,\ldots,g_n)$.
The $\tau^{-1}(j)$th coordinate of $\varphi_{\sigma}(g_1,\ldots,g_n)$ is the $\sigma^{-1}(\tau^{-1}(j))$th coordinate of $(g_1,\ldots,g_n)$.
That is,
$$\begin{align*}
\varphi_{\tau}\circ\varphi_{\sigma}(g_1,\ldots,g_n) &= 
\left(g_{\sigma^{-1}(\tau^{-1}(1))}, g_{\sigma^{-1}(\tau^{-1}(2))},\ldots,g_{\sigma^{-1}(\tau^{-1}(n))}\right)\\
&=\left(g_{\sigma^{-1}\circ\tau^{-1}(1)}, g_{\sigma^{-1}\circ\tau^{-1}(2)},\ldots, g_{\sigma^{-1}\circ\tau^{-1}(n)}\right)\\
&= \left( g_{(\tau\circ\sigma)^{-1}(1)},\ldots,g_{(\tau\circ\sigma)^{-1}(n)}\right)\\
&=\varphi_{\tau\circ\sigma}(g_1,\ldots,g_n).
\end{align*}$$
The error in your calculation is in line 4.
