fixed for loop; error bar rewriting