refactored deleting docs code a little bit