changed apply to sample