Index Out of bounds Exception fix