implemented faster procedure for problem 174
added timing