implemented factorization