Fixed bad reference to key variable