Added web hook support. Broke reusable piece into functions