MD5 algorithm checksum shell scripting. Help me fix the issue

Create_MD5Checksums() {
  directory=$1
  save_dir=`pwd`

  file="MD5_VALUES"
  tmp_file="/tmp/${file}.${pid}"

  rm -f ${tmp_file}

  if [ ! -d "${directory}" ]; then
    errorExit "Directory ${directory} for checksum creation does not exist."
  fi

  cd ${directory}
  chmod +w .

  if [ -f "${xxx}" ]; then
    chmod +w ${file}
    rm -f ${file}
  fi

  for x in `ls`
  do
    if [ ! -d $x ]; then
      digest -va md5 $X >> ${tmp_file}
    fi
  done

  mv ${tmp_file}
  chmod 444 ${directory}/${file}
  cd ${save_dir}

}

MD5 algorithm checksum shell scripting. Help me fix the issue. What ${xxx} do?MD5 algorithm checksum shell scripting. Help me fix the issue. What ${xxx} do?