Refactor delete repo code