recursive function with 2 variables