rewriting print_dir function