Simplification of exercise 3