Bug fix: off-by-one