Fix possible undefined index error