fixed up the upload and read file function