sample.py improvements