refactor ts