functional refactoring