Adding python implementation