You are not handling the term properly in the integral in the top line. Since you are not including this when integrating by parts, I assume you are treating it like this:
After integrating by parts, you are making a substitution in place of the integral in the above line (the part in brackets). So, after your substitution, you get this:
Does this help?