Fix timing for calling notifyDatasetChabge to avoid IllegalStateException