fix issue #238 and #239