update of part b with oliver's solution