implementing new solution to problem 79