modify saving notification, reorganize and cleanup JS code