refactoring for #184, #182, #185