rewrote listen function to use a more modern approach to sockets