replaced headerSent with headersSent