fix index handling