modified a helper function in format.py