got repetitive lines into get_directory_path function.