avoid negative index