some error handling and use the samplerate