changed logic for hasClass function