added comments for g_to_index