A medical device for assisting a function of the heart is provided. The heart is placed in the thorax, the thoracic diaphragm is dividing the thorax from the abdomen and the pericardium is surrounding the heart and is attached to the thoracic diaphragm at a pericardial contacting section of the thoracic diaphragm. The medical device comprises a diaphragm passing part adapted to pass from the abdomen, through the thoracic diaphragm at the pericardial contacting section, into the pericardium, wherein said diaphragm passing part is adapted to allow the thoracic diaphragm to move during respiration, when implanted.