Refactoring into functions.