copying over core data code from book - not finished