bug fixed with negative index access