add reference implementation in python