added isValid method