fix issue #28 and #74