Add update leave logic;
Optimize codes