add file existence checking