function purchasePhoenix(uint256 _phoenixID) whenNotPaused gameInProgress public payable {
      
      require(_phoenixID < 19);
    
      Phoenix storage phoenix = PHOENIXES[_phoenixID];
      
      uint256 price = phoenix.price;
      
      
      require(phoenix.currentOwner != address(0)); 
      require(msg.value >= phoenix.price);
      require(phoenix.currentOwner != msg.sender); 
      
      uint256 outgoingOwnerCut;
      uint256 purchaseExcess;
      uint256 poolCut;
      uint256 rainbowCut;
      uint256 captainCut;
      
      (outgoingOwnerCut, 
      purchaseExcess, 
      poolCut,
      rainbowCut,
      captainCut) = calculateCuts(msg.value,price);
      
      
      userFunds[phoenix.previousOwner] = userFunds[phoenix.previousOwner].add(captainCut); 
      
      
      if (_phoenixID == 0) {
          outgoingOwnerCut = outgoingOwnerCut.add(rainbowCut).add(captainCut);
          rainbowCut = 0; 
          poolCut = poolCut.div(2); 
          POOLS[0] = POOLS[0].add(poolCut); 
          POOLS[1] = POOLS[1].add(poolCut); 
          
      } else if (_phoenixID < 3) { 
          outgoingOwnerCut = outgoingOwnerCut.add(captainCut);
          uint256 poolID = _phoenixID.sub(1); 
          POOLS[poolID] = POOLS[poolID].add(poolCut);
          
      } else if (_phoenixID < 11) { 
          
          userFunds[PHOENIXES[1].currentOwner] = userFunds[PHOENIXES[1].currentOwner].add(captainCut);
          upgradePhoenixStats(_phoenixID);
          POOLS[0] = POOLS[0].add(poolCut); 
      } else {
          
          userFunds[PHOENIXES[2].currentOwner] = userFunds[PHOENIXES[2].currentOwner].add(captainCut);
          upgradePhoenixStats(_phoenixID);
          POOLS[1] = POOLS[1].add(poolCut); 
      }
      
      
      userFunds[PHOENIXES[0].currentOwner] = userFunds[PHOENIXES[0].currentOwner].add(rainbowCut);

      
      phoenix.price = getNextPrice(price);
      
      
      sendFunds(phoenix.currentOwner, outgoingOwnerCut);
    
      
      phoenix.currentOwner = msg.sender;

      
      if (purchaseExcess > 0) {
        sendFunds(msg.sender,purchaseExcess);
      }
      
      
      emit PhoenixPurchased(_phoenixID, msg.sender, price, phoenix.price, phoenix.currentPower, phoenix.abilityAvailTime);
  }