Fixed reading of the numSamples variable