added toggle function and event