refactor Index trait and classes