refactor plugin code.