fix issue #19 and #48