fix bugs (index range)