Updated Recursive approach