fixed stupid bug on range check