added function to check if file exsits