implement and test closing conditions