fighting the almighty off-by-one error