added range check