Refactor Code

Python