heavily revised this code -KL

large revisions were made to generate a better figure 2 -KL