I need help factoring $\displaystyle x^5+2x^3-x^2-2$

I tried it by grouping $\displaystyle (x^5 - x^2) + (2x^3 -2)$

Then I got $\displaystyle x^2(x^3 - 1) + 2(x^3 - 1)$

Thus my final answer was $\displaystyle (x^3 - 1)(x^2+2)$

From there, I had no clue what to do. My text book says the correct answer is $\displaystyle (x^2+2)(x-1)(x^2+x+1)$ but I just have no clue how they got there.

Any help would be appreciated, thanks.