Added insert/delete functions to take care of all cases