Fixed array index issue