I think my problem is in the above code but why there is a range issue?
Size 46 only takes indices between 0 and 45 inclusive.
Got it! Any idea how long it will run? It seems it runs for 10 minutes now.