bug fix with indices