move getIdx into common trait