This is exactly what I was looking for but could you tell me why the recursion was not working?