looking good, need to clean up but this seems to work pending unit tests