exercise 5.6 headOption implemented