The present invention relates generally to methods for implantable medical devices and more particularly to methods for optimizing stimulation of a heart of a patient. The method comprises: determining recommended pacing settings including recommended AV delays and/or recommended W delays based on IEGM data. Further, at least one hemodynamical parameter is determined based on measured at least one hemodynamical signal. Reference pacing settings are determined including reference AV delays and/or reference W delays based on said hemodynamical parameters. An AV delay correction value and a W delay correction value are calculated as a difference between recommended AV and/or VV delays and reference AV and/or W delays, respectively. The correction values are used for updating recommended AV and/or VV delays, respectively.