Refactor hasClass