was outputting incorrect sums due to an indexing error with endBin, and subsequently endBin_value. fixed this now, and r output agrees with doing it manually (on m1 at least)