added isValid check