refactor PR #136. (rebased & force pushed)