formatting bugs
fixed incorrect variable scope in the plotting functions