formatting output content based on header keys