bug fixed with negative index