first version, implemented from wc2utils