rewrote file deletion to be more modular