first work on python implementation