finished part 4,5 of ex4