recursive function is a bit cuter, I htink