tidied union code