finished up to problem 4