improved index with full code