fixing index behaviour on the edge of Integer values