fixed issue #6 and issue #5