refactoring on messages