slightly more elegant way to calculate timeframe