initial add of code that mostly works