added a better logic to prevent replacing other's http code