Made problem 7 faster