add a check on logging to see if already logged and fix headers usage