fix merging logic and values from groups