Added notifications but multithreading code contains a bug