Method and apparatus for preventing heart rhythm disturbances by recording cardiac electrical activity, measuring beat-to-beat variability in the morphology of electrocardiographic waveforms, and using the measured beat-to-beat variability to control the delivery of electrical impulses to the heart during the absolute refractory period.