Renamed variable prev to prev_thresh