improved recursive call