Use 'max' as the limit rather than a hardcoded number

In case the limit ever changes, the code doesn't need to be updated.