implementing index. but not finished yet