refactor, extended lib.t.ds