Done. Re-factored this code into a separate function wait_for_status_change()