Minor edit.
Add some range checking.