recursive function defined but not working