modify the code for sampling rate