solved exercise 3 mostly