factorify
chainify implementation