Changed main_dir to main_dir_chk()