arrange code and get_directory modified