Factoring quadratics with perfect squares