one function//maxfactornum is replaced

still slow