fix issue #1 and fix issue #3