lots of refactoring is called for, but this is a working prototype with the basics of what i would like to achieve.