fix for nil index