Fixing unable to set headers exception