Refactoring of polynom fit