put peer code into its own file