refactoring and added multiple peer connections