Wrote a python version