I sympathise with Sigurd's view that the above belongs in a separate function.