added collection index too large check and some additional arithmetic cases