func: function buyCar(address referal, uint cType, bool give_refund, address new_owner, uint category) public payable returns (bool) {
          require(category == PREMIUM_CATEGORY || category == MID_GRADE_CATEGORY || category == REGULAR_CATEGORY);
          if (category == PREMIUM_CATEGORY) {
              require(cType == 1 || cType == 2 || cType == 3 || cType == 4 || cType == 5, "Invalid car type");
              require(premiumHold > 0, "No more premium cars");
              require(premiumOpen, "Premium store not open for sale");
          } else if (category == MID_GRADE_CATEGORY) {
              require(cType == 6 || cType == 7 || cType == 8, "Invalid car type");
              require(midGradeHold > 0, "No more midgrade cars");
              require(midgradeOpen, "Midgrade store not open for sale");
          } else if (category == REGULAR_CATEGORY) {
              require(cType == 9 || cType == 10 || cType == 11, "Invalid car type");
              require(regularHold > 0, "No more regular cars");
              require(regularOpen, "Regular store not open for sale");
          }
  
          uint256 price = priceFor(cType);
          require(price > 0, "Price not yet set");
          require(msg.value >= price, "Not enough ether sent");
          
          currentTypePrice[cType] = price; 
  
          uint256 _tokenId = factory.mintFor(cType, new_owner); 
          
          if (category == PREMIUM_CATEGORY) {
              premiumCarsBought[cType].push(_tokenId);
              premiumHold--;
          } else if (category == MID_GRADE_CATEGORY) {
              midGradeCarsBought[cType - 5].push(_tokenId);
              midGradeHold--;
          } else if (category == REGULAR_CATEGORY) {
              regularCarsBought[cType - 8].push(_tokenId);
              regularHold--;
          }
  
          if (give_refund && msg.value > price) {
              uint256 change = msg.value - price;
  
              msg.sender.transfer(change);
          }
  
          if (referal != address(0)) {
              require(referal != msg.sender, "The referal cannot be the sender");
              require(referal != tx.origin, "The referal cannot be the tranaction origin");
              require(referal != new_owner, "The referal cannot be the new owner");
  
              
              uint256 totalCommision = COMMISSION_PERCENT + commissionRate[referal];
  
              uint256 commision = (price * totalCommision) / 100;
  
              referal.transfer(commision);
          }
  
          emit CarBought(_tokenId, price, new_owner, category);
      }