fixes #1 using wait-and-notify