Adding core data functions
Fixing core data