Changed to thread.sleep() instead of wait()