Additional refactoring into functions.