updated plotting code. more comments + corrections