Working on refactoring out unecessary ugly python code