Added isValid check