Reply code refactoring