Refactored setRequestHeader to reduce the complexity