Need help interpreting a function

Hi, i was reading through a sample coding and came across this function, can anyone pls help to interpret the code for me. Thank alot

find_lines()
{
    res=-1
    if [ ! -z "$1" ]; then
        grep -i "$@" $FILENAME
        res=$?
    fi
    return $res
}
    res=-1

Assigning a value to a variable; -1 as default return code for this function if there is no parameter given when calling the function.

    if [ ! -z "$1" ]; then

...if the 1st positional parameter of the function find_lines() is not empty then...

        grep -i "$@" $FILENAME

... grep the file(name) contained in $FILENAME by ignoring case (-i) with all parameters given ($@) to the function.

        res=$?

The return code of the grep stored to res.

    fi
    return $res

Ending the if/then/fi and returning the value of res as return code of the function.

There's a problem here. Suppose you call the function like this:
find_lines some words
The arguments of grep will be: "some" "words" "$FILENAME", but grep will interpret "words" a file, not a pattern to search for.
If you change it to "$*", then "some words" would be passed as one argument.

Also, you may want to add switch -q to grep to avoid printing the grep output.

I would rewrite the whole function like this:

function find_words()
{
    test -z "$1"  &&  return -1  ||  grep -q -i "$*" "$FILENAME"
}