Exercise 3.d (not working appropriately)