Fix a bug in the listen function.