Added a timer to determine stop (i.e. stop if done or timed out)