using map to store ID and index