simplified and renamed send_headers() a little