Restructure code and completed example 14