improved plotting script