newer TS refactor