made new waitTime() function