implemented the listen method