copied from etvtool.pl