added terminate_after_time option