implemented condition variables