avoid NSRangeExceptions in subarrayTo/FromIndex if index is out of bounds