Refactored code to MACoreDataManager