fixing dates logic