fixed toggleClass and improved emit