tpl: refactoring