Update util.py

update many logic.
Merge pull request #1 from GuanjunXu/patch-1

Update util.py