Reworked function that sometimes failed.
Reworked function that sometimes failed.

EpiDoc/EFES,EpiDoc/EFES,kcl-ddh/kiln,kcl-ddh/kiln,kcl-ddh/kiln,EpiDoc/EFES,EpiDoc/EFES,EpiDoc/EFES,EpiDoc/EFES,kcl-ddh/kiln,kcl-ddh/kiln,kcl-ddh/kiln,kcl-ddh/kiln