instead of using a flag to read the socket for debugging purposes, a block can be used