Fixing bug in listen method.