moved listener block to finally