Refactor messageService