bug fix https://github.com/AdeleResearchGroup/ApAM/issues/103 (herman solution)