This should be easier to understand now. The comments are updated. There are also alerts for extraordinary situations where the function is passed an unexpected number.