changed InvalidSize to InvalidRange exception when checking for range instead of length