range check is now in the right place