modified cleanDocChannel function