Change: Split functions out from procedural code to make things cleaner.