simplify
slow solution to problem 2