Possible fix for undefined index