refactor into python package