recursive approach