Refactor greeting into a separate function.