made changes from issue #159