Add $key to function parameter

I think it's better to enclose `$key` as function parameter.