Created a callback function to make sure the timing of deleting/creating...

... is in the right order