Fixed issue #83

Needs reviewing and testing for #83