Fix bug in listener