Refactor to use functions in an include file.
Refactor