cleaned up some typos, fixed variable defined in two different senses (joys of rewriting old code), added plotting, tested and it works