Fix undefined index notice bug