modified ybsutils.py