Consolidate helper functions, which are not really needed
exercise 2 code