add utils.py and make the code to be more clear