updated to use min dates