made problem 6 even neater