Rewriting everything in python