Check $key variable is set