added locks to sample