refactoring to typescript