fixed indexout of bounds