Added the code for the basic working model. Should work fine with the random data.