initial s2w dt2w code import from @showp1984