Code to generate closed model, commented it out, algo too dumb.
CODE IS DEMOABLE