crated the delet funntion to delete the file with the refrence
got the files to delete properly