fixed issue #46 and #50