modified r.py