bug fix with index