change mailbox to condition and lock implementation