Improved exercise 3