deleteFiles function corrected