setting up logic for handling directory transmission