If $key is not a string the check might fail