Update util.py

update many logic.