fix undefined index when adding