take end date into consideration