modified the code to include functions for lesson 3