fix issue #4, fix issue #6