tried to fix undefined indexes