A rules engine acquires sensor data from sensors applied to the heart to determine the presence of a rapid heartbeat. The rules engine applies rules to the sensor data to determine whether to deliver an electrical waveform to a vagus nerve. The rules engine further determines whether an electrical waveform should be applied to the heart and, if so, the type of electrical waveform.