Searching directory

The command is to search all the matched directory under $HOME, the input i directory is the last argument
it works perfectly by itself
but after a method call, it wont work cant figure out why

dirNameCheck(){
 for i in $*
 do
   test $1
 done
 noMatch=`find HOME -type d -name $i | wc -l`
 if [ $noMatch -eq 0 ]
 then 
   echo " there is no such directory "
   dir=`pwd`
 else
   dir=$i
 fi
}

if [ $# -lt 1 ]
then 
  echo "Useage : blablabla "
else
  dirNameCheck;
fi

for command
i wrote

sh fileName -name dirName

it displayed as miss argument to -name
no such directory
even there is a directory same as the argument
it still display "there is no such directory"

thank you for helping