initial version coding to mirror the final formulation from the readme
omgz looks like it works :o