Check if $data is array before checking isset

I do not know why, but on my setup, when $data is a string, isset would
return true. Also checking if $data is an array fixes it and should not
cause damage since the only thing we do with tha array is filter it.