Modified the addClass and removeClass methods to use the new hasClass method