Refactoring message managment using pointer