Value of an inverse trigonometric expression

If $p>q>0$ and $pr<-1<qr$ then find the value of $\arctan \dfrac{p-q}{1+pq}+ \arctan\dfrac{q-r}{1+qr}+\arctan\dfrac{r-p}{1+rp}$

Attempt:

Formula used:

$$\arctan p - \arctan q = \arctan\frac{p-q}{1+pq}$$ if $pq>-1$

$\implies \arctan p - \arctan q + \arctan q - \arctan r + \arctan\dfrac{r-p}{1+rp}$

Now, as $p>0$ and $pr<-1$ $\implies r<0$

Formula to be used now:

$$\arctan x - \arctan y = \pi + \arctan \dfrac{x- y}{1+xy}$$ if $x>0 , y< 0 ,xy<-1$

$\implies \arctan p - \arctan r - \arctan \dfrac{p-r}{1+rp}$ $(as \arctan(-x)= -\arctan(x))$

$= \arctan p - \arctan r - (\pi +\arctan p - \arctan r)$

$= -\pi$

But answer given in the book is $\pi$.

Is my approach incorrect? I am quite confident about it.

You were good until you substituted $$\left(\pi+\tan^{-1}p-\tan^{-1}r\right)$$ for $$\tan^{-1}\frac{p-r}{1+pr}$$ because you just showed a line above that that $$\tan^{-1}\frac{p-r}{1+pr}=\tan^{-1}p-\tan^{-1}r-\pi$$ Also try it out on a calculator and you will see your mistake.