refactoring of py-client