this is now working for problem 2, as well as problem 1