Updated code with xcode-generated template for Core Data