Add class check to isValid