Refactoring for message class