putting the delete calls in a better spot