Completed the extra credit for exercise 3.