add timetomax condition