delete file process refactored