Deleting duplicate files and modify DB connecting