The present invention relates generally to implantable medical devices and more particularly to systems for stimulating a heart of a patient. The system includes a cardiac stimulator connectable to a hemodynamic sensor adapted to sense hemodynamic signals. In addition, the system comprises a control module adapted to control settings of said cardiac stimulator to deliver pacing signals in accordance with preset AV and VV delays, and an optimization module adapted to optimize an AV and VV delay based on IEGM signals to determine recommended AV and VV delays. A data processing module is adapted to: determine a delay control parameter for each preset AV delay and VV delay based on the collected hemodynamic signals for respective preset AV delay and VV delay; determine the AV delay setting that corresponds to the maximum delay control parameter and the VV delay setting that corresponds to the maximum delay control parameter; determine an AV delay error correction value as a difference between the AV delay corresponding to the maximum delay control parameter and a recommended AV delay; and determine a VV delay error correction value as a difference between the VV delay corresponding to the maximum delay control parameter and a recommended VV delay.