Added a python implementation