update example to use is_valid()