Updated to fix retval for wait_for