refine code, extract utility.py