implementation of factorizer