improved index handling