refactoring for #179, #180, #181