Refactoring client code, use TypeScript