initial working version. test case(s) pending.