still need to fix the bug of using index