stop using yield to call recursive func