Put the code in a function. Preparation for objects.
Trying to understand the example.