Changed to recursive solution.