changed sync to allow arbitrary user defined headers