improved response headers logic
logic improvements
formatting