factorize method