Fix for undefined indexes