refactored based on plugin template