code now checks that the user specified value is within expected range