Added check for array key existence (was failing).