first solution to exercise 1