added time termination condition