solution to problem number 6