attempted fix of issue #18

Here's my stab at this problem. It seems to work for me.