Add waitFor and debug log