define var at the top
before filter check lenght of current set
better hasClass logic, removed unnecessary bytes, added .data() and .removeData() methods