factoring code