added exercise 3 and extended version