Added compacting function to output