modified to add union functionality