Refactor peer's code to make it more readable