fix off-by-1