Refactor to use more functional style.