Restructured Python Code