fix an error and improve demo for CoreData