On the relationship between coronal mass ejections and magnetic clouds