Code runs, factorization fails