add global time constraint as a feature
sanity check shows the correctness of the algorithm by now