Fix DeprecationWarning in util.py