Changed var sample to volatile.