some refactoring, and improve msg notification