implements exercise 3.5: first and second