update sample functions to solve encoding problem