completed exercise 5 (with pattern matching). only exercise 4 to go