refactoring create polynomial function