even shorter version of exercise 17