fixed the bug reported by Don, more tests needed.
Merge remote-tracking branch 'origin/master'