Refactoring into Pure Functions