Code refactoring for network messages