improved isValidator function