refactor the codes, and abstract a message service
refactoring the MessageService  to add callback