fix undefined index error