fix #38 and #40