Added coredata logic