I am not sure if  MAX_SAFE_INTEGER will always correlate to the maximum length. I'll go ahead and move this out of the function. I had it like that before, not sure why I stuck it back in there.