Re-factored main.py