better output ref capturing