relay: tighten up code to make it more precise