Move wrapping logic to a method and out of backend=.