finished modifications for exercise 4-6