homework 6 - factorization - partly implemented