updated to more optimized call
changed signature of wait_for_string