fix bug in the script where the prev.percent had the wrong values