cleaner implementation similar to buildChain instrument