clean code, support python interface