added wait_for function to protocol_core