replace listagg with custom function