improve webhook handling code and comments