fixed #48 and #40