Make this into a python package (or at the very least, refactor it into functions and follow best practices)
Make this into a python package (or at the very least, refactor it into functions and follow best practices)