Using maxtime function and randomizing task duration