Improve valid.py
Improve valid.py (minor change)