fixed bug in wait_for_open method