Fixed bug that caused an undefined index error - now we check the key before checking...