issue #1 fixed efficiency of problem 3