add a recursive function for logout