refactor peer manager