Refactoring to curried nad partially applied functions