support functions to calculate deadline