cleaning up python code