Refactor the code, using observer mode to handle message. Write little recorder code