fixed a bug in listener that caused stack to crash