Extracted out similar behavior in shift, pop, and sample.