Refactoring util/main.py