move event emitters outside of socket io call