getSelectedValues() from list giving error

I have a list who’s dataset is populated by copying another dataset (bound to a sql query (polling off) at window open.
I also have a button that when pressed runs a script that copies the selected rows to another list. The underlying dataset(s) have three columns (of course only one is visible in the list).
The script runs without issue every time unless I select ALL rows in the list. When all rows are selected, I get the error shown below.

Ignition Version:
7.7.2

Line of code generating error:

selectedValues = event.source.parent.getComponent('lstAvailSecurityType').getSelectedValues()

Error:
Traceback (most recent call last):

File “event:actionPerformed”, line 13, in

java.lang.ArrayIndexOutOfBoundsException: java.lang.ArrayIndexOutOfBoundsException: 31

caused by ArrayIndexOutOfBoundsException: 31

Ignition v7.7.2 (b2014121709)
Java: Oracle Corporation 1.8.0_45

Edit:
Found the issue in the way i was selecting the objects (programmatically). Using AddSelectionInterval from 0 to rowCount should be rowCount - 1.