finally managed to make listener working without deadlocks