refactoring type script