moved build_transaction to a more logical place