Added range check: Fix #1.