Updated main_dir check