Get rid of duplicate restrict code