clean up the python code