improved performance of 'hasClass' method