Fixed another bug which causes crash on leave