move listenandserve into their own functions because they block