Added ability to control sampling rate