added filtration to remove bad characters from directories