fix 1st example: move waitFor to where it belongs