Fix for off-by-one error