# How does $\frac{x^2 + 6x + 5}{x^2 - x - 2}$ simplify to $\frac{(x + 5)(x + 1)}{(x - 2)(x + 1)}$?

I stumbled upon following rational, where the right hand of equation is a simplification:

$$\frac{x^2 + 6x + 5}{x^2 - x - 2} = \frac{(x + 5)(x + 1)}{(x - 2)(x + 1)}$$

1. I can't understand how do you derive this simplification, what rules apply here?

2. Secondly, I want to search google for more (generic) information but I'm not even sure what should I search for?

EDIT:

Btw. this comes from this video link, but it doesn't explain my question.

1) Find the roots of the numerator. These are $$-5, -1$$, Find the roots of the denominator. These are $$2, -1$$.