solving exercise 12