Auto call functions when leave some function