adjust use of waitTime and fix syntax error on global varialbe change