fixed issue #14 and #21