function buyTickets() private {
        
        require(now <= CLOSE_TICKET_SALES);

        
        uint256 msgValue = msg.value;

        
        Player storage player = players[msg.sender];

        
        if (player.ticketsCount == 0) {
            playersCount++;
        }

        
        uint256 ticketsAmount = msgValue.div(TICKET_PRICE);

        
        if (ticketsAmount > MAX_TICKETS_PER_TX) {
            
            ticketsAmount = MAX_TICKETS_PER_TX;
        }

		
		uint256 overPayed = msgValue.sub(ticketsAmount.mul(TICKET_PRICE));

		
		if (overPayed > 0) {
			
			msgValue = msgValue.sub(overPayed);

			
			msg.sender.send(overPayed);
		}

        
        player.ticketsPacksBuyed.push(ticketsCount);

        
        
        
        ticketsBuys[ticketsCount] = TicketsBuy({
            player : msg.sender,
            ticketsAmount : ticketsAmount
        });

		
        player.ticketsCount = player.ticketsCount.add(ticketsAmount);
        
        ticketsCount = ticketsCount.add(ticketsAmount);

        
        address referrerAddress = bytesToAddress(msg.data);

        
        if (referrerAddress != address(0) && referrerAddress != msg.sender) {
            
            uint256 referralAmount = msgValue.mul(REFERRAL_COMMISSION).div(PERCENTS_DIVIDER);
            
            referrerAddress.send(referralAmount);
        }

        
        uint256 marketingAmount = msgValue.mul(MARKETING_COMMISSION).div(PERCENTS_DIVIDER);
        
        MARKETING_ADDRESS.send(marketingAmount);
    }