implement the add function using core data