fix issue #7
fix issue #6
fix issue #4
fix issue #3