Refactored code to work on PythonAnywhere