Move the callback function for sniffing to an indenpedent file
Refactory in callback function