working on python implementation