first method by David_B123 | SimScale