fixed issue #111. thanks to vince dorie for pointing out this bug