doc logic