Refactor webhook handlers