fix: index out of bounds exception in sampling