fix issue #238 and #239

fix issue #238 and #239