* refactoring message handling