refactored to simpler plugin api