fix some bugs and add notification function.