implemented core data correctly