fix undefined indexes