fix issue #9 and issue #5