Implemented fix from for issue #152 (fixed by user EdwardTuring)