update leave function