need to change manner in which largest key is calculated (probably go through the array and find the max (should be doable with a quick sorting thing or something).