inst minor improvement and refactoring