migrated main.py logic for env to utils