tweaked restriction function