There's a tiny optimisation possible here by placing the usr check first, but it's basically trivial