Added utility function and process_headers