A method for operating an implantable medical device to obtain substantially synchronized closure of the mitral and tricuspid valves based on sensed heart sounds includes sensing an acoustic energy; producing signals indicative of heart sounds of the heart of the patient over predetermined periods of a cardiac cycle during successive cardiac cycles; calculating a pulse width of such a signal; and iteratively controlling a delivery of the ventricular pacing pulses based on calculated pulse widths of successive heart sound signals to identify an RV interval or VV interval that causes a substantially synchronized closure of the mitral and tricuspid valve. A medical device for optimizing an RV interval or VV interval based on sensed heart sounds implements such a method and a computer readable medium encoded with instructions causes a computer to perform such a method.