move the emit calls into their own functions