Improved upon fix put in last commit. for loop upper bound was using the rightIndex rather than the size of the array.