written an UDF to convert a tuple into a bag. It needs testing though