tested in the smu server and fixed a bug for the wait