I'm assuming the bd = db kind of multiplication is already assumed to be commutative, or else you'd have yourself a circular argument. Multiply out the last line (foil it), and you'll get the second-to-last line. So, from the second-to-last line to the last line is a matter of factoring. Since foiling it out gets you the desired result, the method of factoring, whatever it was, was valid.