started converting code to python