Refactor webhooks handling