add leave function