Added a parameter for waiting.