cleaned up python code